#!/bin/bash
#数据库创建
curl -X PUT 'localhost:9200/accounts?pretty=true' -d '
{
  "mappings": {
    "person": {
      "properties": {
        "user": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word"
        },
        "title": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word"
        },
        "desc": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word"
        }
      }
    }
  }
}'  -H "Content-Type: application/json"

#添加数据
curl -X PUT 'localhost:9200/accounts/person/1?pretty=true' -d '
{
    "user" : "王二麻",
    "title" : "DBA",
    "desc" : "DBA"
}' -H "Content-Type: application/json"

curl -X PUT 'localhost:9200/accounts/person/2?pretty=true' -d '
{
    "user" : "张三",
    "title" : "工程师",
    "desc" : "数据库管理，软件开发"
}' -H "Content-Type: application/json"


curl -X PUT 'localhost:9200/accounts/person/3?pretty=true' -d '
{
    "user" : "李四",
    "title" : "程序猿",
    "desc" : "码农"
}' -H "Content-Type: application/json"

#查询
curl 'localhost:9200/accounts/person/_search?pretty=true' -H "Content-Type: application/json"

curl 'localhost:9200/accounts/person/_search?pretty=true'  -d '
{
  "query" : { "match" : { "desc" : "软件" }}
}'  -H "Content-Type: application/json"

#指定位移
 curl 'localhost:9200/accounts/person/_search'  -d '
{
  "query" : { "match" : { "desc" : "管理" }},
  "from": 1,
  "size": 1
}'




































